/**
 * 
 */
package com.gr.staffpm.dhtmlx.datatypes;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamOmitField;


/**
 * @author Graham Rhodes 21 Jan 2011 11:42:35
 */
public class Task implements Serializable {

    private static final long serialVersionUID = 1L;
    private int id = 0;
    private String name = "";
    private String est = "";
    private long duration = 0;
    private double percentcompleted = 0;
    private List<Task> predecessortasks = new ArrayList<Task>();
    private List<Task> childtasks = new ArrayList<Task>();
    @XStreamOmitField
    private final transient SimpleDateFormat df = new SimpleDateFormat("yyyy,MM,dd");

    public Task() {

    }

    public Task(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getEst() {
        return est;
    }

    public Date getEstAsDate() {
        try {
            return df.parse(est);
        } catch (ParseException e) {
        }
        return null;
    }

    public long getDuration() {
        return duration;
    }

    public double getPercentcompleted() {
        return percentcompleted;
    }

    public List<Task> getPredecessortasks() {
        return predecessortasks;
    }

    public void addChildTask(Task task) {
        this.childtasks.add(task);
    }

    public List<Task> getChildtasks() {
        return childtasks;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setEst(String est) {
        this.est = est;
    }

    public void setEst(Date est) {
        this.est = df.format(est);
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public void setPercentcompleted(double percentcompleted) {
        this.percentcompleted = percentcompleted;
    }

    public void setPredecessortasks(List<Task> predecessortasks) {
        this.predecessortasks = predecessortasks;
    }

    public void setChildtasks(List<Task> childtasks) {
        this.childtasks = childtasks;
    }

}
